package com.demo.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.demo.common.lang.Result;
import com.demo.entity.Category;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * 生活服务信息Controller
 * 
 * @author 1111
 * @date 2023-12-02
 */
@RestController
@RequestMapping("/system/category")
public class CategoryController extends BaseController<Category>
{


    /**
     * 查询生活服务信息列表
     */
//    @PreAuthorize("@ss.hasPermi('system:category:list')")
    @GetMapping("/list")
    public Result list(Category category)
    {
        QueryWrapper<Category> wrapper = new QueryWrapper<>(category);
        Page<Category> page = categoryService.page(getPage(), wrapper);
        return Result.succ(page);
    }


    /**
     * 获取生活服务信息详细信息
     */
    @GetMapping(value = "/{id}")
    public Result getInfo(@PathVariable("id") Long id)
    {
        return Result.succ(categoryService.selectCategoryById(id));
    }

    /**
     * 新增生活服务信息
     */
    @PostMapping
    public Result add(@RequestBody Category category)
    {
        return Result.reselut(categoryService.insertCategory(category));
    }

    /**
     * 修改生活服务信息
     */
    @PutMapping
    public Result edit(@RequestBody Category category)
    {
        return Result.reselut(categoryService.updateCategory(category));
    }

    /**
     * 删除生活服务信息
     */
//	@DeleteMapping("/{ids}")
//    public Result remove(@PathVariable Long[] ids)
    @DeleteMapping
    public Result remove( Long[] ids)
    {
        return Result.reselut(categoryService.deleteCategoryByIds(ids));
    }
}
